package com.itttq.kb.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.itttq.kb.model.po.TopicCategoryPo;
import com.itttq.kb.model.to.PageParamTo;
import com.itttq.kb.service.TopicCategoryService;

@RestController
@RequestMapping("topicCategory")
public class TopicCategoryController extends GenericController {
	private static final long serialVersionUID = -74483466987146288L;
	@Autowired
	private TopicCategoryService topicCategoryService;
	
	@RequestMapping("topicCategorys")
	public ModelAndView getTopicCategorys(TopicCategoryPo topicCategory, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/sys/topicCategorys");
		PageParamTo ppt = this.getPageParam(request);
		this.getPageMv("topicCategorys", mv, topicCategoryService.getTopicCategorys(topicCategory, ppt), topicCategoryService.getTopicCategoryCount(topicCategory), ppt);
		mv.addObject("topicCategory", topicCategory);
		return mv;
	}
	
//	/**
//	 * 跳转到新增页面
//	 * @param prod
//	 * @param request
//	 * @return
//	 */
//	@RequestMapping("addTopicCategory")
//	public ModelAndView addTopicCategory(Integer id, HttpServletRequest request) {
//		ModelAndView mv = new ModelAndView("/sys/adAdd");
//		if(id != null) {
//			mv.addObject("topicCategory", topicCategoryService.getTopicCategoryById(id));
//		}
//		return mv;
//	}
//
//	@RequestMapping("saveTopicCategory")
//	public ModelAndView saveTopicCategory(TopicCategoryPo topicCategory, HttpServletRequest request) {
//		topicCategoryService.saveTopicCategory(topicCategory);
//		return getTopicCategorys(new TopicCategoryPo(), request);
//	}
//
//	@RequestMapping("delTopicCategory")
//	@ResponseBody
//	public ResultTo delTopicCategory(Integer id, HttpServletResponse response) {
//		ResultTo rt = new ResultTo(ResultTo.FAIL);
//		if(id != null) {
//			topicCategoryService.delTopicCategory(id);
//			rt.setCode(ResultTo.SUCCESS);
//		}
//		return rt;
//	}
}
